package com.online.sevice_video.controller;

import com.online.common_utils.ResultJson;
import com.online.sevice_video.service.VideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("service_video/video")
public class VideoController {

    @Autowired
    private VideoService videoService;


    @PostMapping("upload")
    public ResultJson uploadVideo(MultipartFile file){
        String videoId=videoService.aliyunUploadVide(file);
        return ResultJson.ok().data("vId",videoId);
    }

    @DeleteMapping("delete/{sourceId}")
    public ResultJson deleteVideo(@PathVariable String sourceId){
        videoService.aliyunDeleteVideo(sourceId);
        return ResultJson.ok();
    }
    @DeleteMapping("deleteVideoList")
    public ResultJson deleteVideoList(@RequestParam("videoIdList") List<String> videoIdList){
        videoService.aliyunDeleteVideoByListId(videoIdList);
        return ResultJson.ok();
    }

}
